package com.j4dream.bufferedWriter;

/* 给定线程数 每个线程执行的文件数量为一定数值
 * 将一个完整的文件数量拆分成多个文件 每个线程插入相应的拆分文件记录*/
public class smallTest implements Runnable {
	private static long skipNumber = 3;
	private static long skipThread = 10;
	private static long totalRecords = 45;

	public static void main(String[] args) {
		long everyThreadNumber;
		long fileCount;
		if (totalRecords < skipNumber * skipThread) {
			everyThreadNumber = totalRecords / skipThread;
			if (everyThreadNumber != 0) {
				for (int i = 0; i < skipThread - 1; i++) {
					System.out.println(everyThreadNumber);
				}
			}
			System.out.println(totalRecords - everyThreadNumber * (skipThread - 1));
		}
		if (totalRecords == skipNumber * skipThread) {
			long fullRecords = totalRecords / (skipNumber * skipThread);
			for (int i = 0; i < fullRecords * skipThread; i++) {
				System.out.println(skipNumber);
			}
		}
		if (totalRecords > skipNumber * skipThread) {
			long fullRecords = totalRecords / (skipNumber * skipThread);
			long remainRecords = totalRecords - (skipNumber * skipThread) * fullRecords;
			for (int i = 0; i < fullRecords * skipThread; i++) {
				System.out.println(skipNumber);
			}
			System.out.println("remainCount:" + remainRecords);
			everyThreadNumber = remainRecords / skipThread;
			for (int i = 0; i < skipThread - 1; i++) {
				System.out.println(everyThreadNumber);
			}
			System.out.println(remainRecords - everyThreadNumber * (skipThread - 1));
		}
	}

	@Override
	public void run() {
		// TODO Auto-generated method stub
		System.out.println("Test project!");
	}
}
